package com.beaut.project.control;

import java.util.Map;
import java.util.UUID;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.beaut.project.service.FinanceService;



/**
 * 财务管理
 * @author jzk
 *
 */
@Controller
@RequestMapping("/finance")
public class FinanceController extends BaseControl{
	@Autowired
	private FinanceService financeService;
	
	@RequestMapping(value = "/listPageFinanceCompany", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public @ResponseBody String listPageFinanceCompany(HttpServletRequest request) {
    	Map<String, Object> map = getPagerMap(request);
    	map.putAll(requestParameterToMap(request));
    	return financeService.listPageFinanceCompany(map);
    }
	 /**
     *根据用户id查询出借款金额
     * @param request
     * @return
     */
    @RequestMapping(value = "/getUserSumLoanMoney",method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public @ResponseBody String getUserSumLoanMoney(HttpServletRequest request) {
    	return financeService.getUserSumLoanMoney(requestParameterToMap(request));
    }
	
	 /**
     * 员工借款报账列表
     * @param request
     * @return
     */
    @RequestMapping(value = "/listPageEmployeeReimburseme",method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public @ResponseBody String listPageEmployeeReimburseme(HttpServletRequest request) {
    	Map<String, Object> map = getPagerMap(request);
    	map.putAll(requestParameterToMap(request));
    	return financeService.listPageEmployeeReimburseme(map);
    }
    /**
     * 员工借款详细信息
     * @param request
     * @return
     */
    @RequestMapping(value = "/getEmployeeReimbursemeById", method = RequestMethod.GET, produces = "text/html;charset=UTF-8")
    public @ResponseBody String getEmployeeReimbursemeById(HttpServletRequest request) {
    	return financeService.getEmployeeReimbursemeById(requestParameterToMap(request));
    } 
  @RequestMapping(value = "/addEmployeeReimburseme", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public @ResponseBody String addEmployeeReimburseme(HttpServletRequest request) {
    	return financeService.addEmployeeReimburseme(requestParameterToMap(request));
    }
    @RequestMapping(value = "/updateEmployeeReimburseme", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public @ResponseBody String updateEmployeeReimburseme(HttpServletRequest request) {
    	return financeService.updateEmployeeReimburseme(requestParameterToMap(request));
    }
    @RequestMapping(value = "/deleteEmployeeReimburseme", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public @ResponseBody String deleteEmployeeReimburseme(HttpServletRequest request) {
    	return financeService.deleteEmployeeReimburseme(requestParameterToMap(request));
    }
    
	 /**
     * 员工借款列表
     * @param request
     * @return
     */
    @RequestMapping(value = "/listPageEmployee",method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public @ResponseBody String listPageEmployee(HttpServletRequest request) {
    	Map<String, Object> map = getPagerMap(request);
    	map.putAll(requestParameterToMap(request));
    	return financeService.listPageEmployee(map);
    }
    /**
     * 财务实际放款更新
     * @param request
     * @return
     */
    @RequestMapping(value = "/updateEmployActualLoan", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public @ResponseBody String updateEmployActualLoan(HttpServletRequest request) {
    	return financeService.updateEmployActualLoan(requestParameterToMap(request));
    }
    /**
     * 财务实际放款更新
     * @param request
     * @return
     */
    @RequestMapping(value = "/updateWorkerActualLoan", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public @ResponseBody String updateWorkerActualLoan(HttpServletRequest request) {
    	return financeService.updateWorkerActualLoan(requestParameterToMap(request));
    }
    /**
     * 财务实际收款更新
     * @param request
     * @return
     */
    @RequestMapping(value = "/updateEmployYetLoan", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public @ResponseBody String updateEmployYetLoan(HttpServletRequest request) {
    	return financeService.updateEmployYetLoan(requestParameterToMap(request));
    }
    
    /**
     * 员工借款详细信息
     * @param request
     * @return
     */
    @RequestMapping(value = "/getEmployeeById", method = RequestMethod.GET, produces = "text/html;charset=UTF-8")
    public @ResponseBody String getEmployeeById(HttpServletRequest request) {
    	return financeService.getEmployeeById(requestParameterToMap(request));
    } 
  @RequestMapping(value = "/addEmployee", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public @ResponseBody String addEmployee(HttpServletRequest request) {
    	return financeService.addEmployee(requestParameterToMap(request));
    }
    @RequestMapping(value = "/updateEmployee", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public @ResponseBody String updateEmployee(HttpServletRequest request) {
    	return financeService.updateEmployee(requestParameterToMap(request));
    }
    @RequestMapping(value = "/deleteEmployee", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public @ResponseBody String deleteEmployee(HttpServletRequest request) {
    	return financeService.deleteEmployee(requestParameterToMap(request));
    }
	@RequestMapping(value = "/listPageFinanceDept", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
	public @ResponseBody String listPageFinanceDept(HttpServletRequest request) {
		Map<String, Object> map = getPagerMap(request);
		map.putAll(requestParameterToMap(request));
		return financeService.listPageFinanceDept(map);
	}
	@RequestMapping(value = "/listPageFinanceDeptLog", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
	public @ResponseBody String listPageFinanceDeptLog(HttpServletRequest request) {
		Map<String, Object> map = getPagerMap(request);
		map.putAll(requestParameterToMap(request));
		return financeService.listPageFinanceDeptLog(map);
	}
	@RequestMapping(value = "/listGdYetAdvancesByYetId", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
	public @ResponseBody String listGdYetAdvancesByYetId(HttpServletRequest request) {
		return financeService.listGdYetAdvancesByYetId(requestParameterToMap(request));
	}
	@RequestMapping(value = "/listXmPayWorkerDetail", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
	public @ResponseBody String listXmPayWorkerDetail(HttpServletRequest request) {
		return financeService.listXmPayWorkerDetail(requestParameterToMap(request));
	}
	@RequestMapping(value = "/listPageFinanceCompanyLog", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
	public @ResponseBody String listPageFinanceCompanyLog(HttpServletRequest request) {
		Map<String, Object> map = getPagerMap(request);
		map.putAll(requestParameterToMap(request));
		return financeService.listPageFinanceCompanyLog(map);
	}
	@RequestMapping(value = "/getFinanceCompanyById", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
	public @ResponseBody String getFinanceCompanyById(HttpServletRequest request) {
		return financeService.getFinanceCompanyById(requestParameterToMap(request));
	}
	@RequestMapping(value = "/addFinanceCompany", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
	public @ResponseBody String addFinanceCompany(HttpServletRequest request) {
		Map<String, Object> map = requestParameterToMap(request);
		Map<String, Object> sessionMap = (Map<String, Object>) request.getSession().getAttribute("LOGIN_USER");
		map.put("person_id", sessionMap.get("id"));
		map.put("person", sessionMap.get("truename"));
		return financeService.addFinanceCompany(map);
	}
	@RequestMapping(value = "/addFinanceDept", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
	public @ResponseBody String addFinanceDept(HttpServletRequest request) {
		Map<String, Object> map = requestParameterToMap(request);
		Map<String, Object> sessionMap = (Map<String, Object>) request.getSession().getAttribute("LOGIN_USER");
		map.put("person_id", sessionMap.get("id"));
		map.put("person", sessionMap.get("truename"));
		return financeService.addFinanceDept(map);
	}
	@RequestMapping(value = "/addFinanceDeptByOneKey", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
	public @ResponseBody String addFinanceDeptByOneKey(HttpServletRequest request) {
		Map<String, Object> map = requestParameterToMap(request);
		Map<String, Object> sessionMap = (Map<String, Object>) request.getSession().getAttribute("LOGIN_USER");
		map.put("person_id", sessionMap.get("id"));
		map.put("person", sessionMap.get("truename"));
		return financeService.addFinanceDeptByOneKey(map);
	}
	@RequestMapping(value = "/updateFinanceCompany", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
	public @ResponseBody String updateFinanceCompany(HttpServletRequest request) {
		return financeService.updateFinanceCompany(requestParameterToMap(request));
	}
	@RequestMapping(value = "/deleteFinanceCommons", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
	public @ResponseBody String deleteFinanceCommons(HttpServletRequest request) {
	    return financeService.deleteFinanceCommons(requestParameterToMap(request));
	}
	@RequestMapping(value = "/updateFinanceCommons", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
	public @ResponseBody String updateFinanceCommons(HttpServletRequest request) {
	    return financeService.updateFinanceCommons(requestParameterToMap(request));
	}
	@RequestMapping(value = "/addFinanceCommons", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
	public @ResponseBody String addFinanceCommons(HttpServletRequest request) {
	    return financeService.addFinanceCommons(requestParameterToMap(request));
	}
   @RequestMapping(value = "/listPageFinanceCommons", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public @ResponseBody String listPageFinanceCommons(HttpServletRequest request) {
        Map<String, Object> map = getPagerMap(request);
        map.putAll(requestParameterToMap(request));
        return financeService.listPageFinanceCommons(map);
    }
   @RequestMapping(value = "/listPageFinanceLoan", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
   public @ResponseBody String listPageFinanceLoan(HttpServletRequest request) {
       Map<String, Object> map = getPagerMap(request);
       map.putAll(requestParameterToMap(request));
       return financeService.listPageFinanceLoan(map);
   }
   @RequestMapping(value = "/listPageFinanceLoanYet", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
   public @ResponseBody String listPageFinanceLoanYet(HttpServletRequest request) {
       Map<String, Object> map = getPagerMap(request);
       map.putAll(requestParameterToMap(request));
       return financeService.listPageFinanceLoanYet(map);
   }
   @RequestMapping(value = "/addFinanceLoan", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
	public @ResponseBody String addFinanceLoan(HttpServletRequest request) {
		Map<String, Object> map = requestParameterToMap(request);
		String id= UUID.randomUUID().toString();
		map.put("id", id);
		return financeService.addFinanceLoan(map);
	}
   @RequestMapping(value = "/addFinanceYetLoan", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
	public @ResponseBody String addFinanceYetLoan(HttpServletRequest request) {
		Map<String, Object> map = requestParameterToMap(request);
		String id= UUID.randomUUID().toString();
		map.put("id", id);
		return financeService.addFinanceYetLoan(map);
	}
   @RequestMapping(value = "/updateFinanceLoan", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
   public @ResponseBody String updateFinanceLoan(HttpServletRequest request) {
   	return financeService.updateFinanceLoan(requestParameterToMap(request));
   }
   @RequestMapping(value = "/getFinanceLoanById", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
   public @ResponseBody String getFinanceLoanById(HttpServletRequest request) {
       return financeService.getFinanceLoanById(requestParameterToMap(request));
   }
   @RequestMapping(value = "/getFinanceLoanYetById", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
   public @ResponseBody String getFinanceLoanYetById(HttpServletRequest request) {
       return financeService.getFinanceLoanYetById(requestParameterToMap(request));
   }
   @RequestMapping(value = "/deleteFinanceLoan", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
   public @ResponseBody String deleteFinanceLoan(HttpServletRequest request) {
   	return financeService.deleteFinanceLoan(requestParameterToMap(request));
   }
   @RequestMapping(value = "/listPageFinanceCommons1", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
   public @ResponseBody String listPageFinanceCommons1(HttpServletRequest request) {
	   Map<String, Object> map = getPagerMap(request);
	   map.putAll(requestParameterToMap(request));
	   return financeService.listPageFinanceCommons1(map);
   }
   @RequestMapping(value = "/listPageFinanceCommonDetail", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
   public @ResponseBody String listPageFinanceCommonDetail(HttpServletRequest request) {
	   Map<String, Object> map = getPagerMap(request);
	   map.putAll(requestParameterToMap(request));
	   return financeService.listPageFinanceCommonDetail(map);
   }
   @RequestMapping(value = "/listFinanceCommonsDetail", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
   public @ResponseBody String listFinanceCommonsDetail(HttpServletRequest request) {
       return financeService.listFinanceCommonsDetail(requestParameterToMap(request));
   }

   @RequestMapping(value = "/getFinanceCommonsById", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
   public @ResponseBody String getFinanceCommonsById(HttpServletRequest request) {
       return financeService.getFinanceCommonsById(requestParameterToMap(request));
   }
   /**
    * 公共费用放款
    */
   @RequestMapping(value = "/updateFianceActualLoan", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
   public @ResponseBody String updateFianceActualLoan(HttpServletRequest request) {
       return financeService.updateFianceActualLoan(requestParameterToMap(request));
   }
   /**
    * 借款放款
    */
   @RequestMapping(value = "/updateFianceActualLoanOut", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
   public @ResponseBody String updateFianceActualLoanOut(HttpServletRequest request) {
       return financeService.updateFianceActualLoanOut(requestParameterToMap(request));
   }
	@RequestMapping(value = "/listFinanceDept", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
	public @ResponseBody String listFinanceDept(HttpServletRequest request) {
		return financeService.listFinanceDept();
	}

}
